﻿<%@ Page Language="c#" ContentType="text/html" ResponseEncoding="utf-8" Async="true" MasterPageFile="~/administration/master_popup.master" Inherits="ACM.cmsarea08.Administration.Controls.OptMenuItemChooser" %>
<%@ MasterType VirtualPath="~/administration/master_popup.master" %>
<asp:Content ID="PageBody" Runat="server" ContentPlaceHolderID="MasterBody">
<div id="option_popup">
<div class="popup_msgs">
<% Response.Write(rm.GetString("insert_menuitem")); %></div>
<div class="popup_input">
<span id="controlli" runat="server"></span>
</div>
<div class="popup_btms">
<input id="confirm_choose" type="button" value="<% Response.Write(rm.GetString("next_button")); %> ->" disabled="disabled" onclick="javascript=myClick();" />
</div>

</div>

<script language="javascript" type="text/javascript">
var tipo = "input";
var tipos = "radio";
var valueNOT = "";
var valueSelect="";
var mioParente = "";


function disableButton() {
	var opt_cont = document.getElementById('option_popup');
	if(opt_cont == null ) return;
	var inputs = opt_cont.getElementsByTagName('input');
	if(inputs == null ) { opt_cont = null; return; }
	for(var i = 0 ; i<inputs.length; i++ ) {
		if(inputs[i].getAttribute("type") =="button") {
			inputs[i].setAttribute("disabled","disabled");		
		}
	}
	inputs = null;
	opt_cont = null;
}
function enableButton() {
	var opt_cont = document.getElementById('option_popup');
	if(opt_cont == null ) return;
	var inputs = opt_cont.getElementsByTagName('input');
	if(inputs == null ) { opt_cont = null; return; }
	for(var i = 0 ; i<inputs.length; i++ ) {
		if(inputs[i].getAttribute("type") =="button") {
			inputs[i].removeAttribute("disabled") ;		
		}
	}
	inputs = null;
	opt_cont = null;
}


function init_me() {
	//alert('<% Response.Write(Request.QueryString["findid"]); %>');
	var hid_cont = top.document.getElementById('<% Response.Write(Request.QueryString["findid"]); %>');
	if(hid_cont!=null) {
		mioParente = hid_cont.value;
	}
	hid_cont=null;
	var opt_cont = document.getElementById('option_popup');
	if(opt_cont == null ) return;
	//primo ciclo imposto pulsante  - blocco standard
	var inputs = opt_cont.getElementsByTagName('input');
	if(inputs == null ) { opt_cont = null; return; }
	for(var i = 0 ; i<inputs.length; i++ ) {
		if(inputs[i].getAttribute("type") =="button") {
			inputs[i].setAttribute("disabled","disabled");		
		}
	}
	inputs = null;
	//secondo ciclo cerco il tipo e imposo la funzione di valueNOT
	inputs = opt_cont.getElementsByTagName(tipo);
	if(inputs == null ) { opt_cont = null; return; }
	for(var i = 0 ; i<inputs.length; i++ ) {
		if(inputs[i].getAttribute("type") ==tipos) {
			inputs[i].onclick = Convalida;	
		}
	}
	inputs = null;
	opt_cont = null;
}
function Convalida(e) {
	e = e || event; 
	var obj = e.target || e.srcElement; 
	var switcher = e.type + '/' + obj.tagName +(obj.tagName == 'INPUT' ? '/' + obj.type : '');
	valueSelect = obj.value;
	if(obj.value!=valueNOT) {
		enableButton();
	} else {
		disableButton();
	}
}
function myClick() {
	top.SmoothBoxGoToUrl("../core/edit_menuitem.aspx?new=1&idf=0&idmc="+mioParente+"&idtv=" + valueSelect);

}



init_me();
</script>

</asp:content>
